package n1840;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {

	static int[] base=new int[100];
	
	static int a[]=new int[5];
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{

		for(int i=-50;i<=50;i++)
		{
			if(i<0)base[i+50]=i*i*i;
			else if(i>0)base[i+50-1]=i*i*i;
		}
		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(bf.readLine());
		for(int i=0;i<5;i++)
		{
			a[i]=Integer.parseInt(st.nextToken());
		}
		
		
		HashMap<Integer,Integer> map=new HashMap<Integer,Integer>();
		
		
		
		for(int i=0;i<100;i++)
			for(int j=0;j<100;j++)
			{
				int key=base[i]*a[3]+base[j]*a[4];
				
				if(map.containsKey(key))
				{
					int cnt=map.get(key);
					map.put(key, cnt+1);
				}else{
					map.put(key, 1);
				}
			}
		
		int ans=0;
		for(int i=0;i<100;i++)
			for(int j=0;j<100;j++)
				for(int k=0;k<100;k++)
				{
					int key=base[i]*a[0]+base[j]*a[1]+base[k]*a[2];
					if(map.containsKey(-key))
					{
						ans+=map.get(-key);
					}
				}
		
		System.out.println(ans);
		
	}

}
